/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.action;

import com.sun.istack.internal.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author ipalmaqu
 */
public class LoginAction extends org.apache.struts.action.Action {

    private static final Logger logger = Logger.getLogger(LoginAction.class);
    
    /* forward name="success" path="" */
    private static final String SUCCESS = "success";
    private static final String FAILURE = "failure";

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        logger.info("execute() : Inicio");
        LoginForm miForm = (LoginForm) form;
        String target = "";
        String usuario = miForm.getUsuario();
        String password = miForm.getPassword();
        
        if((null == usuario)||("".equals(usuario))){
            logger.info("Error, ingreso de Usuario");
                    
            target ="FAILURE";
        }else{
            if((null == password)||("".equals(password))){
                 logger.info("Error, ingreso de Password");
                target ="FAILURE";
            }else{
                
                
                
                target = "SUCCESS";
            }
        }
        logger.info("execute() : Fin");
        return mapping.findForward(target);
    }
}
